﻿{include file='pub@pub/header'/}
<title>标签列表</title>
</head>
<body class="pos-r">
<div>
    <nav class="breadcrumb">
        {$breadNav}
        <a class="btn btn-success radius r btn-refresh" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" >
            <i class="Hui-iconfont">&#xe68f;</i>
        </a>
    </nav>
    <div class="page-container">
        <div class="cl pd-5 bg-1 bk-gray mt-20">
            <span class="l">
                <a class="btn btn-primary radius" onclick="tag_add('添加标签','{:url(\'Product/addTag\')}')" href="javascript:;">
                    <i class="Hui-iconfont">&#xe600;</i> 添加标签
                </a>
            </span>
            <span class="r">总共有数据：<strong>{$totalNum}</strong>条</span>
        </div>
        <div class="mt-20">
            <table class="table table-border table-bordered table-bg table-hover table-sort">
                <thead>
                    <tr class="text-c">
                        <th width="40">ID</th>
                        <th width="100">产品标签名称</th>
                        <th width="100">操作</th>
                    </tr>
                </thead>
                <tbody>
                {foreach $list as $item}
                <tr class="text-c va-m">
                    <td>{$item.id}</td>
                    <td>
                        {$item.tag_name}
                    </td>
                    <td class="td-manage">
                        <a style="text-decoration:none" class="ml-5"
                           onClick="tag_add('标签编辑','{:url(\'Product/addTag\', [\'id\'=>$item.id])}')"
                           href="javascript:;" title="标签编辑">
                            <i class="Hui-iconfont">&#xe6df;</i>标签编辑
                        </a>
                        <a style="text-decoration:none" class="ml-5" onClick="tag_del(this,'{$item.id}')"
                           href="javascript:;" title="删除">
                            <i class="Hui-iconfont">&#xe6e2;</i>删除
                        </a>
                    </td>
                </tr>
                {/foreach}
                </tbody>
            </table>
            {$list->render()}
        </div>
    </div>
</div>

{include file='pub@pub/footer'/}
<script type="text/javascript">
    // $('.table-sort').dataTable();

    /*产品-添加*/
    function tag_add(title, url) {
        var index = layer.open({
            type: 2,
            title: title,
            content: url,
            area:["400px", "250px"]
        });
        // layer.full(index);
    }

    /*产品-删除*/
    function tag_del(obj, id) {
        layer.confirm('确认要删除吗？', function (index) {
            $.post("{:url('Product/delTag')}", {idstr:id}, function (res) {
                if(res.code == 1){
                    layer.msg('删除成功');
                    $(obj).parents('tr').remove();
                }else{
                    layer.msg(res.msg);
                }
            });
        });
    }
</script>
</body>
</html>